(function ($) {
    $.fn.extend({
        "dialog":function (options) {
            if(typeof(options)=="object"){
                var modal='<div class="modal fade" data-backdrop="static">\
                    <div class="modal-dialog">\
                    <div class="modal-content">\
                    <div class="modal-header">\
                    <span class="close" data-dismiss="modal">&times;</span>\
                    <h3 class="modal-title"></h3>\
                    </div>\
                    <div class="modal-body">\
                    </div>\
                    <div class="modal-footer">\
                    <button class="btn btn-default" data-dismiss="modal"><i class="glyphicon glyphicon-remove"></i>取消</button>\
                    <button class="btn btn-danger"><i class="glyphicon glyphicon-ok"></i>确定</button>\
                    </div>\
                    </div>\
                    </div>\
                    </div>';

                var opt={
                    title:"&nbsp;",
                    btnName:"确定",
                    btnBind:null
                };

                for(var p in options){
                    opt[p]=options[p]||opt[p];
                }

                var $modal=$(modal);
                $modal.find(".modal-title").html(opt.title);
                $modal.find(".modal-body").append(this);
                $modal.find(":button:last").val(opt.btnName);
                $modal.find(":button:last").off("click").on("click",opt.btnBind);
                $modal.appendTo("body");
            }else if("open"==options){
                this.parents(".modal").modal("show");
            }else if("close"==options){
                this.parents(".modal").modal("hide");
            }
        }
    })
})(jQuery)